package sangpil.temp
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import sangpil.temp.event.TempEvent;

	[Event(name = 'tempEvent', type='sangpil.temp.event.TempEvent')]
	public class TempClass extends Sprite
	{
		public function TempClass()
		{
			super();
			var temper:MovieClip = makeRect();
			this.addChild(temper);
			temper.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
			trace('go');
		}
		
		private function makeRect():MovieClip
		{
			var tempMc:MovieClip = new MovieClip();
			with(tempMc.graphics)
			{
				beginFill(0x3478ee);
				drawRect(0, 0, 50, 50);
				endFill();
			}
			return tempMc;
		}
		
		private function onDown(e:MouseEvent):void
		{
			e.currentTarget.x = Math.random()*800;
			var obj:Object = new Object();
			obj.mc = e.currentTarget;
			this.dispatchEvent(new TempEvent(obj, TempEvent.TEMP_EVENT));
		}
		
	}
}